/**
 * Cookie存储
 * @param {String} key 键
 * @param {Object} val 值
 * @param {Number} time 时间，默认为10s
 */
 function setCookie(key,val,time = 10)
 {
     if(typeof val == 'object') val = JSON.stringify(val)

     const date = new Date

     date.setTime(date.getTime() - 1000*60*60*8 + 1000*time)

     document.cookie = `${key}=${val};expires=${date}`
 }
 

 /**
  * Cookie获取
  * @param {String} key 键
  * @returns String
  */
 function getCookie(key)
 {

     let arr = document.cookie.split('; ')

     for(let i=0;i<arr.length;i++)
     {
         let item = arr[i]

         let tempArr = item.split('=')

     if(tempArr[0]==key) return tempArr[1]
     }
 }
 


 /**
  * Cookie删除
  * @param {String} key 键
  * @returns undefined
  */
 function removeCookie(key)
 {
     setCookie(key,null,-1)
 }